package com.ihd.ihardware.view.tzc.health.view;

import android.app.ActionBar;
import android.arch.lifecycle.AndroidViewModel;
import android.os.Bundle;
import android.widget.FrameLayout;
import android.widget.ImageView;

import com.ihd.ihardware.R;
import com.ihd.ihardware.databinding.SolutionFragmentBinding;

import cn.wowjoy.commonlibrary.base.BaseFragment;

public class SolutionFragment extends BaseFragment<SolutionFragmentBinding, AndroidViewModel> {

    private int src;
    private ImageView iv;

    public static SolutionFragment newInstance(int param1) {
        SolutionFragment fragment = new SolutionFragment();
        Bundle args = new Bundle();
        args.putInt("src", param1);
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            src = getArguments().getInt("src");
            iv = new ImageView(getContext());
            iv.setImageResource(src);
            iv.setLayoutParams(new FrameLayout.LayoutParams(ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.WRAP_CONTENT));
            iv.setAdjustViewBounds(true);
        }
    }

    @Override
    protected void onCreateViewLazy(Bundle savedInstanceState) {
        binding.container.addView(iv);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.solution_fragment;
    }

    @Override
    protected Class getViewModelClass() {
        return AndroidViewModel.class;
    }
}
